@extends('layouts.home')
@section('content')
    <div class="card mt-2">
        <div class="card-header">
            博客列表
        </div>
        <div class="card-block">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>作者</th>
                    <th>文章标题</th>
                    <th>发布时间</th>
                    <th>修改时间</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($blogs as $v)
                    <tr>
                        <td scope="row">{{$v['id']}}</td>
                        <td>{{$v->user->username}}</td>
                        <td>{{$v['title']}}</td>
                        <td>{{$v['created_at']}}</td>
                        <td>{{$v['updated_at']}}</td>
                        <td>
                            <div class="btn-group" role="group" aria-label="Basic example">
                                <a href="{{route('blog.show',$v)}}" class="btn btn-outline-success">查看</a>
                                @can('update',$v)
                                    <a href="{{route('blog.edit',$v)}}" class="btn btn-outline-info">编辑</a>
                                @endcan
                                @can('delete',$v)
                                    <form action="{{route('blog.destroy',$v)}}" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-outline-danger">删除</button>
                                    </form>
                                @endcan
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="card-footer text-muted" >
            <div style="text-align: center">
                {{$blogs->links()}}
            </div>
        </div>

@endsection